#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int N=2e5+10;
#define INF 0x3f3f3f3f;
typedef long long int ll;
#define close(); std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
//----------------------------------------------------------------------------//

int days[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
bool check_day(int& year, int& month, int& day)
{
	if (month == 0 || month > 12) return false;
	if (day == 0) return false;
	if (month != 2)
	{
		if (day > days[month]) return false;
	}
	else
	{
		int leap = year % 100 && year % 4 == 0 || year % 400 == 0;
		if (day > 28 + leap) return false;
	}
	return true;
}

int main()
{
	close();
	
	int a,b,c;
	cin>>a>>b>>c;
	
	int aa=18+a;
	if(check_day(aa,b,c)) cout<<aa<<" "<<b<<" "<<c<<'\n';
	else cout<<-1<<'\n';


	return 0;
}